package com.gw.jpa.service.impl;

import com.gw.jpa.entity.Grade;
import com.gw.jpa.repository.GradeRepository;
import com.gw.jpa.service.GradeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class GradeServiceImpl implements GradeService {
    @Autowired //自动注入
    private GradeRepository gradeRepository;
    @Override
    public Grade getGrade(Integer gid) {
        return gradeRepository.findById(gid).get();
    }

    @Override
    public Grade addGrade(Grade grade) {
        return gradeRepository.save(grade);
    }

    @Override
    public Grade updateGrade(Grade grade) {
        return gradeRepository.save(grade);
    }

    @Override
    public List<Grade> getGradeJquery() {
        return gradeRepository.findAll();
    }

    @Override
    public void deleteGrade(Integer gid) {
        gradeRepository.deleteById(gid);
    }
}
